package pers.books.serviceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import pers.books.dao.BookDao;
import pers.books.entity.Book;
import pers.books.service.BookService;
import pers.books.util.ResultMessage;

/**
 * 
 * BookServiceImpl
 *
 * @author 姜治昊
 * @time 2018年4月30日 下午7:52:27
 */
@Service
public class BookServiceImpl implements BookService {
	
	@Autowired
	private BookDao bookDao;
	
	@Override
	public ResultMessage<Book> getBookById(String id) {
		// TODO Auto-generated method stub
		try {
			Book book = bookDao.getBookById(id);
			if(null == book || null == book.getId()) {
				return ResultMessage.createErrorResultMessage("暂无数据，请重试！", null);
			}
			return ResultMessage.createSuccessResultMessage("获取成功", book);
		} catch(Exception e) {
			e.printStackTrace();
			return null;
		}
		
	}

}
